﻿@model IOA.MES.DataAccess.VModel.VPackCondition
@{
    ViewBag.Title = "包装条件配置";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}

<div id="page"></div>

<script type="text/template" id="tplPage">
    <div style="background-color:white;padding:10px;margin:15px">
        <div class="layui-form">
            <input type="hidden" name="OrderNo" value="@ViewBag.OrderNo" />
            <input type="hidden" name="WorkOrderNo" value="@ViewBag.WorkOrderNo" />
            <input type="hidden" name="QLevelCondition" value="@ViewBag.QLevelCondition" />
            <div class="layui-form-item">
                <label class="layui-form-label">{{lang.Field.FullPackQuantity}}</label>
                <div class="layui-input-inline">
                    <input type="number" name="QuantityLimit" min="0" value="@(Model?.QuantityLimit)" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" pane="">
                <label class="layui-form-label">{{lang.Field.PackCondition}}</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="OrderNoLimit" lay-skin="primary" title="订单号" @(Model?.OrderNoLimit ?? false ? "checked" : "")>
                    <input type="checkbox" name="WorkOrderNoLimit" lay-skin="primary" title="工单号" @(Model?.WorkOrderNoLimit ?? false ? "checked" : "")>
                    <input type="checkbox" name="DataPlate" lay-skin="primary" title="铭牌型号" @(Model?.DataPlate ?? false ? "checked" : "")>
                    <input type="checkbox" name="RatedPower" lay-skin="primary" title="额定功率" @(Model?.RatedPower ?? false ? "checked" : "")>
                    <input type="checkbox" name="ElectricGrade" lay-skin="primary" title="电流档" @(Model?.ElectricGrade ?? false ? "checked" : "")>
                    <input type="checkbox" name="CompGrade" lay-skin="primary" title="组件等级" @(Model?.CompGrade ?? false ? "checked" : "")>
                    <input type="checkbox" name="CompColor" lay-skin="primary" title="组件颜色" @(Model?.CompColor ?? false ? "checked" : "")>
                    <input type="checkbox" name="JunBoxSpecs" lay-skin="primary" title="接线盒规格" @(Model?.JunBoxSpecs ?? false ? "checked" : "")>
                    <input type="checkbox" name="JunBoxFactory" lay-skin="primary" title="接线盒厂家" @(Model?.JunBoxFactory ?? false ? "checked" : "")>
                    <input type="checkbox" name="BackPlanSpecs" lay-skin="primary" title="背板规格" @(Model?.BackPlanSpecs ?? false ? "checked" : "")>
                    <input type="checkbox" name="BackPlanFactory" lay-skin="primary" title="背板厂家" @(Model?.BackPlanFactory ?? false ? "checked" : "")>
                    <input type="checkbox" name="AluFrameSpecs" lay-skin="primary" title="铝框规格" @(Model?.AluFrameSpecs ?? false ? "checked" : "")>
                    <input type="checkbox" name="AluFrameFactory" lay-skin="primary" title="铝框厂家" @(Model?.AluFrameFactory ?? false ? "checked" : "")>
                    <input type="checkbox" name="BatterySpecs" lay-skin="primary" title="电池片规格" @(Model?.BatterySpecs ?? false ? "checked" : "")>
                    <input type="checkbox" name="BatteryFactory" lay-skin="primary" title="电池片厂家" @(Model?.BatteryFactory ?? false ? "checked" : "")>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn " lay-submit lay-filter="submit">{{lang.Field.Submit}}</button>
                </div>
            </div>
        </div>
    </div>
</script>

@section Scripts{
    <script>
        var vm = new Vue({
            el: "#page",
            template: "#tplPage",
            data: {
                lang: JSON.parse(lang).package
            }
        });
        setTimeout(function () {
            initLayui();
        }, 50);
        function initLayui() {
            layui.use(['form', 'layer'], function () {
                var layer = layui.layer,
                    form = layui.form;

                form.on('submit(submit)', function (data) {
                    console.log(data.field);
                    var loadId = layer.load();
                    $.ajax({
                        url: "/ParaSetting/EditPackCondition",
                        data: {
                            OrderNo: data.field.OrderNo,
                            WorkOrderNo: data.field.WorkOrderNo,
                            QuantityLimit: data.field.QuantityLimit.trim() == "" ? null : parseInt(data.field.QuantityLimit.trim()),
                            QLevelCondition: parseInt(data.field.QLevelCondition),
                            OrderNoLimit: data.field.OrderNoLimit ? true : false,
                            WorkOrderNoLimit: data.field.WorkOrderNoLimit ? true : false,
                            DataPlate: data.field.DataPlate ? true : false,
                            RatedPower: data.field.RatedPower ? true : false,
                            ElectricGrade: data.field.ElectricGrade ? true : false,
                            CompGrade: data.field.CompGrade ? true : false,
                            CompColor: data.field.CompColor ? true : false,
                            JunBoxSpecs: data.field.JunBoxSpecs ? true : false,
                            JunBoxFactory: data.field.JunBoxFactory ? true : false,
                            BackPlanSpecs: data.field.BackPlanSpecs ? true : false,
                            BackPlanFactory: data.field.BackPlanFactory ? true : false,
                            AluFrameSpecs: data.field.AluFrameSpecs ? true : false,
                            AluFrameFactory: data.field.AluFrameFactory ? true : false,
                            BatterySpecs: data.field.BatterySpecs ? true : false,
                            BatteryFactory: data.field.BatteryFactory ? true : false
                        },
                        complete: function () {
                            layer.close(loadId);
                        },
                        success: function (res) {
                            if (res.ErrCode != 200) {
                                layer.msg(res.ErrMsg, { icon: 5 });
                                return;
                            }
                            layer.msg("保存成功！", { icon: 6, time: 1500 });
                        }
                    });
                    return false;
                });
            });
        }
    </script>
}
